package it.patterns.creational.singleton;

/**
 * 
 * Ensure that a class has only one instance and provide access to it.
 * 
 * <img src="Singleton.jpg" alt="Pattern Structure"/>
 * 
 * @author Luca D'Onofrio
 * 
 * @category Creational Pattern
 * @see "Design Patterns - Element of Reusable Object Oriented Software (Gamma,Helm, Johnson, Vlissides)"
 * 
 * @version 1.0
 * 
 */
public class Singleton {
	private static Singleton instance = null;
	private String data = new String("No Data");

	public void setData(String data) {
		this.data = data;
	}

	public String getData() {
		return data;
	}

	private Singleton() {
	}

	public static Singleton getInstance() {
		if (instance == null)
			instance = new Singleton();

		return instance;

	}

}
